package pluginMain;

import java.util.logging.Logger;

import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class PermCreator extends JavaPlugin {
	public final String PLUGIN_NAME = "PermCreator Plugin";
	public final Logger CONSOLE_LOGGER = this.getLogger();
	public void LOGCONSOLE(String msg){
		CONSOLE_LOGGER.info(msg);
	}
	
	
	@Override
	public void onEnable(){
		LOGCONSOLE(PLUGIN_NAME + " has been started.");
	}
	
	@Override
	public boolean  onCommand(CommandSender sender, Command command,
			String label, String[] args) {
		if(sender instanceof Player && sender.hasPermission("gm.self")){
			if(((Player)sender).getGameMode() == GameMode.SURVIVAL){
				((Player)sender).setGameMode(GameMode.CREATIVE);
			}else{
				((Player)sender).setGameMode(GameMode.SURVIVAL);
			}
		}
		return true;
	}
	
	@Override
	public void onDisable(){
		LOGCONSOLE(PLUGIN_NAME + " has been disabled.");
	}
	
}
